﻿using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2025-05-13
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 工艺参数下发记录
    /// </summary>
    [Verify]
    [Route("business/CksTechniqueLog")]
    [ApiExplorerSettings(GroupName = "business")]
    public class CksTechniqueLogController : BaseController
    {
        /// <summary>
        /// 工艺参数下发记录接口
        /// </summary>
        private readonly ICksTechniqueLogService _CksTechniqueLogService;

        public CksTechniqueLogController(ICksTechniqueLogService CksTechniqueLogService)
        {
            _CksTechniqueLogService = CksTechniqueLogService;
        }

        /// <summary>
        /// 查询工艺参数下发记录列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "ckstechniquelog:list")]
        public IActionResult QueryCksTechniqueLog([FromQuery] CksTechniqueLogQueryDto parm)
        {
            var response = _CksTechniqueLogService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询工艺参数下发记录详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "ckstechniquelog:query")]
        public IActionResult GetCksTechniqueLog(long Id)
        {
            var response = _CksTechniqueLogService.GetInfo(Id);

            var info = response.Adapt<CksTechniqueLogDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加工艺参数下发记录
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "ckstechniquelog:add")]
        [Log(Title = "工艺参数下发记录", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCksTechniqueLog([FromBody] CksTechniqueLogDto parm)
        {
            var modal = parm.Adapt<CksTechniqueLog>().ToCreate(HttpContext);

            var response = _CksTechniqueLogService.AddCksTechniqueLog(modal);

            return SUCCESS(response);
        }




        /// <summary>
        /// 更新工艺参数下发记录
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "ckstechniquelog:edit")]
        [Log(Title = "工艺参数下发记录", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCksTechniqueLog([FromBody] CksTechniqueLogDto parm)
        {
            var modal = parm.Adapt<CksTechniqueLog>().ToUpdate(HttpContext);
            var response = _CksTechniqueLogService.UpdateCksTechniqueLog(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除工艺参数下发记录
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "ckstechniquelog:delete")]
        [Log(Title = "工艺参数下发记录", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCksTechniqueLog([FromRoute] string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_CksTechniqueLogService.Delete(idArr));
        }

    }
}